package com.example.qq;

import android.os.Bundle;
import android.widget.RadioGroup;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.example.qq.Constants.ARouterPath;
import com.example.qq.config.BaseActivity;
import com.example.qq.databinding.ActivityMainBinding;
import com.example.qq.fragment.FirstFragment;
import com.example.qq.fragment.SecondFragment;
import com.example.qq.fragment.ThirdFragment;

@Route(path = ARouterPath.MAIN_ACT)
public class MainActivity extends BaseActivity<ActivityMainBinding> implements RadioGroup.OnCheckedChangeListener {
    private FirstFragment firstFragment = new FirstFragment();
    private SecondFragment secondFragment = new SecondFragment();
    private ThirdFragment thirdFragment = new ThirdFragment();

    @Override
    protected int fillLayout() {
        return R.layout.activity_main;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        mBinding.rg.setOnCheckedChangeListener(this);
        mBinding.rbOne.performClick();
    }

    @Override
    public void onCheckedChanged(RadioGroup group, int checkedId) {
        switch (checkedId) {
            case R.id.rb_one:
                getSupportFragmentManager().beginTransaction().replace(R.id.frameLayout,firstFragment).commit();
                break;
            case R.id.rb_two:
                getSupportFragmentManager().beginTransaction().replace(R.id.frameLayout,secondFragment).commit();
                break;
            case R.id.rb_three:
                getSupportFragmentManager().beginTransaction().replace(R.id.frameLayout,thirdFragment).commit();
                break;
        }
    }


}